import java.util.Scanner;

class NoThisSoundException extends Exception{
    public NoThisSoundException() { super(); }
    public NoThisSoundException(String message) { super(message); }
}
class player{
    public void play(int index) throws NoThisSoundException {
        if(index>10) { throw new NoThisSoundException("“您播放的歌曲不存在的”"); }
        else System.out.println("正在播放音乐");
    }
}
public class my_try_catch {

    public static void main(String[] args) {
        player Piano = new player();
        Scanner input1 = new Scanner(System.in);
        System.out.print("请输入钢琴歌曲序号（最大为10）:>");
        int a1 = input1.nextInt();
        try{ Piano.play(a1); }
        catch (NoThisSoundException e)  { System.out.println("异常信息为："+e.getMessage()); }
        player Violin = new player();
        Scanner input2 = new Scanner(System.in);
        System.out.print("请输入小提琴歌曲序号（最大为10）:>");
        int a2 = input2.nextInt();
        try{ Violin.play(a2); }
        catch (NoThisSoundException e) { System.out.println("异常信息为："+e.getMessage()); }
    }
}

